<?php

	class Mysql {
	
		var $qid;
		var $id;
		
		
		function Mysql(){
		
			$GLOBALS['id'] = mysql_connect('localhost','phpdig_john','132abvq');
			mysql_select_db('phpdig_MyDigest', $GLOBALS['id']);
			
		}
		
		function query($query,$auto_call=FALSE){
		
			if(!($GLOBALS['qid'] = mysql_query($query,$GLOBALS['id']))){
				echo '<div id="error"><h1>An Error Occured</h1>
					<span class="date">Fatal Error</span>
					<p>Due to technical reasons our database server has been taken offline. 
					Please check back within 2 to 5 minutes time</p></div>';
				return FALSE;
			}
			
			if($auto_call===TRUE){
				return Mysql::fetch_array($GLOBALS['qid']);
			}
			
			return $GLOBALS['qid'];
		}
		
		function fetch_array($r){
			return mysql_fetch_array($r);
			
		}
		
		function close(){
			mysql_close($GLOBALS['id']);
			unset($GLOBALS['id']);
			unset($GLOBALS['qid']);
		}
		
	}
	
?>